﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizzReports;

namespace TraysStatsReport
{
    
    public partial class TrayMsgReportUsercontrol : BizzReportTemplate
    {
       
        private TraysMessageCountReport cmd;
        //private BindingSource bindingDataTable = new BindingSource();

        

        public TrayMsgReportUsercontrol(IBizzCommand sourceCmd)
            :base(sourceCmd)
        {
            //InitializeComponent();
            cmd = (TraysMessageCountReport)sourceCmd;
            initTrayMsgReportUserControl();
            
        }

        private void initTrayMsgReportUserControl()
        {
            //tsRefresh.Image = global::TraysStatsReport.Properties.Resources.arrow_refresh_icon;
            tableLayoutPanel1.SetRowSpan(dgContent, 2);
            fromDate.DataBindings.Add("Value", cmd.fromDate, null, false, DataSourceUpdateMode.OnPropertyChanged);
            toDate.DataBindings.Add("Value", cmd.toDate, null, false, DataSourceUpdateMode.OnPropertyChanged);
            dgContent.RowHeadersVisible = false;
            dgContent.AutoGenerateColumns = true;
            cmd.Update();
            dgContent.DataSource = cmd.reportData;
            dgContent.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgContent.AlternatingRowsDefaultCellStyle.BackColor = Color.Gainsboro;
            tsRefresh.Click+=new EventHandler(tsRefresh_Click);
            
            

        }


        public override void tsRefresh_Click(object sender, EventArgs e)
        {
            cmd.fromDate = fromDate.Value;
            cmd.toDate = toDate.Value;
            cmd.Update();
            dgContent.DataSource = cmd.reportData;
        }
    }
}
